package com.example.httptest.service.impl;

import cn.hutool.core.lang.Console;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.example.httptest.service.HttpService;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: dengping.xu
 * @Data: 2021-12-06
 */
public class HttpServiceImpl implements HttpService {

    public static void main(String[] args) {
        String url = "https://mp.huameitai.com/anns/order/reg/reg";
        Map<String, String> map = new HashMap<>();
        map.put("Host","mp.huameitai.com");
        //Host: mp.huameitai.com
        map.put("Connection","keep-alive");
        //Connection: keep-alive
        map.put("Content-Length","142");
        //Content-Length: 142
        map.put("Accept","application/json, text/plain, */*");
        //Accept: application/json, text/plain, */*
        map.put("nlp","0");
        //nlp: 0
        map.put("User-Agent","Mozilla/5.0 (Linux; Android 11; Redmi K30 Pro Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/045811 Mobile Safari/537.36 MMWEBID/2760 MicroMessenger/8.0.16.2040(0x28001057) Process/tools WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64");
        //User-Agent: Mozilla/5.0 (Linux; Android 11; Redmi K30 Pro Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/045811 Mobile Safari/537.36 MMWEBID/2760 MicroMessenger/8.0.16.2040(0x28001057) Process/tools WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64
        map.put("tk","e0804c92-8923-466e-ac43-f0acf6530871");
        //tk: e0804c92-8923-466e-ac43-f0acf6530871
//        map.put("Content-Type","application/json;charset=UTF-8");
        //Content-Type: application/json;charset=UTF-8
        map.put("Origin","https://mp.huameitai.com");
        //Origin: https://mp.huameitai.com
        map.put("Sec-Fetch-Site","same-origin");
        //Sec-Fetch-Site: same-origin
        map.put("Sec-Fetch-Mode","cors");
        //Sec-Fetch-Mode: cors
        map.put("Sec-Fetch-Dest","empty");
        //Sec-Fetch-Dest: empty
        map.put("Referer","https://mp.huameitai.com/reg/confirm/75/1011?date=2021-12-09&beginTime=08%3A00&endTime=11%3A30&inst=7");
        //Referer: https://mp.huameitai.com/reg/confirm/75/1013?date=2021-12-07&beginTime=08%3A00&endTime=11%3A30&inst=7
        map.put("Accept-Encoding","gzip, deflate, br");
        //Accept-Encoding: gzip, deflate, br
        map.put("Accept-Language","zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
        //Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
        map.put("Cookie","mcos.mpws=s%3A8Hb8sd4QaCwNEKvnGSnmy4UzLTly--a4.ezpvofRohnN6BucMq277r1zeuNrul93vZJYUfktnyaM");
        //Cookie: mcos.mpws=s%3A8Hb8sd4QaCwNEKvnGSnmy4UzLTly--a4.ezpvofRohnN6BucMq277r1zeuNrul93vZJYUfktnyaM

        Map<String, Object> paramMap = new HashMap<>();


        /*paramMap.put("payMode","1");
        paramMap.put("payCnl","WX");
        paramMap.put("pid",337152);
        paramMap.put("instId","7");*/

        paramMap.put("date","2021-12-09");
        paramMap.put("beginTime","08:00");
        paramMap.put("endTime","11:00");
        paramMap.put("deptId","75");
        paramMap.put("staffId","1011");
        paramMap.put("payMode",1);
        paramMap.put("payCnl","WX");
        paramMap.put("instId","7");
        paramMap.put("pid",337152);

        //链式构建请求
        HttpResponse result2 = HttpRequest.post(url)
                .addHeaders(map)//头信息，多个头信息多次调用此方法即可
                .form(paramMap)//表单内容
                .execute();
        Console.log(result2);
    }
}
